﻿//-----------------------------------------------------------------------
// <copyright file="Util.cs" company="OpenSource">
//     All code is Microsoft Public License (Ms-PL)
// </copyright>
// <history>
// 2013.02  Created         Chris Hand
// </history>
//-----------------------------------------------------------------------
namespace OpenSource.TumblrAPI.Support
{
    using System;

    /// <summary>
    /// Various helper methods
    /// </summary>
    public static class Util
    {
        /// <summary>
        /// Takes the time specified, coverts it to UTC and the compute a timestamp from it
        /// </summary>
        /// <param name="time">Local time</param>
        /// <returns>A timestamp in UTC</returns>
        public static string ComputeTimeStampFromLocalTime(DateTime time)
        {
            TimeSpan diff = time.ToUniversalTime() - new DateTime(1970, 1, 1);
            string result = Convert.ToInt64(diff.TotalSeconds).ToString();
            return result;
        }
    }
}
